package com.ruoyi.caiwu.params;


import com.ruoyi.caiwu.dto.PageInfo;

import java.util.List;

@lombok.ToString
public class BusinessPageSearchParam<T> {
	//IN
	private int pageNum;
	private int pageSize;
	
	//OUT
	private long totalNum;
	private List<T> records;
	
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public long getTotalNum() {
		return totalNum;
	}
	public void setTotalNum(long totalNum) {
		this.totalNum = totalNum;
	}
	public int getReturnNum() {
		if (this.records == null) {
			return 0;
		}
		return this.records.size();
	}
	public List<T> getRecords() {
		return records;
	}
	public void setRecords(List<T> records) {
		this.records = records;
	}
	public int getTotalPages() {
        if (this.pageSize == 0) {
            return 0;
        }
        return (int) ((this.totalNum + this.pageSize - 1) / this.pageSize);
	}
	
	public PageInfo getPageInfo() {
		return new PageInfo(getPageNum(), getTotalPages());
	}
}
